const state = {
  associatedRowList: new Map(), // 已关联Row集合
  showModal: false, // 关联商品（spu维度）模态框开关
  searchClassifyModal: false // 当商品分类为精准搜索时，商品分类模态框开关
}
const mutations = {
  /* 关联 */
  ASSOCIATED_GOODS: (state, data) => {
    let { row, type } = data
    let name = type || 'uuid'
    state.associatedRowList.set(row[name], row)
  },
  /* 取消关联 */
  CANCEL_GOODS: (state, data) => {
    let { row, type } = data
    let name = type || 'uuid'
    state.associatedRowList.delete(row[name])
  },
  /* 打开或关闭弹框 */
  CHANGE_MODAL_SWITCH: (state, data) => {
    state.showModal = data
  },
  /* 清空 */
  CLEAR_GOODS: (state, data) => {
    state.associatedRowList.clear()
  },
  /* 所有state状态都清空 */
  DESTORY_STATE: (state, data) => {
    state.associatedRowList.clear()
    state.showModal = false
  },
  /* 商品分类模态框打开或关闭 */
  CONTROL_CLASSIFY_MODAL: (state, data) => {
    state.searchClassifyModal = data
  }
}
export default {
  namespaced: true,
  state,
  mutations
}
